package com.hsd.znsh.repository;

import com.hsd.znsh.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/*
 * @auther: wangjiacai
 *
 * @create: 2018-04-23 11:54:50
 */
public interface UserRepository extends JpaRepository<User,Integer> {

    User findByUsername(String username);

    User findByPhone(String phone);

    User findByUsernameAndDeleted(String username,Integer deleted);

    User findByPhoneAndDeleted(String phone,Integer deleted);

    User findByUsernameAndDeletedAndUserType(String username,Integer deleted,Integer userType);

    @Query("select id from User where deleted=0 and username like %?1%")
    List<Integer> findIdListByUsernameLike(String username);

    List<User> findByIdInAndDeleted(List<Integer> userIds,Integer deleted);

    List<User> findByUsernameLikeAndUserType(String username,Integer userTy);

}
